<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="system" tagdir="/WEB-INF/tags/system"%>

<probiz:pageHeading pageHeadingKey="membershipDetail.title" />
<content tag="buttons">
	<probiz:iconBtn btnType="save" onclick="return fnDoSave(this);" />
	<probiz:iconBtn btnType="back" url="${ctxPath}/system/frontMembership.html" />
</content>
<probiz:showBindErrors bindPath="membership.*" />
<div class="top clearfix">
	<ul class="tab">
		<li class="curr"><span>
			<fmt:message key="membershipDetail.title"/>
			</span></li>
	</ul>
</div>

<!-- grant role window start-->
<div id="roleSelectorDiv" style="position:absolute;width:540px;height:320px;display:none"></div>
<!-- grant role window end-->

<form class="mainForm" method="post" action="${ctxPath}/system/frontMembership.html" id="membership">
	<input type="hidden" name="membershipId" value="${membership.membershipId}"/>
	<div class="modify">
		<table  width="100%" border="0" cellspacing="0" cellpadding="0" class="com_modi_table">
			<tr>
				<th colspan="2" class="title"><h4><fmt:message key="appRole.roleAssign"/></h4></th>
			</tr>
			<tr>
				<th><StoreAdmin:label key="appUser.roles"/></th>
				<td><select id="appRoleIds" name="appRoleIds" multiple="multiple" style="width:200px;" class="selecttxt">
						<c:forEach items="${allRoles}" var="appRole">
							<option value="${appRole.roleId}">${appRole.roleName}</option>
						</c:forEach>
					</select>
					<input type="button" onclick="document.getElementById('appRoleIds').selectedIndex=-1;" value="&nbsp;<fmt:message key="resource.roles.clear"/>&nbsp;" class="btn-common"/> 
			</tr>
			<tr>
				<th colspan="2" class="title"><h4><fmt:message key="membership.group.basic"/></h4></th>
			</tr>
			<tr>
				<th class="label_width_1"> <StoreAdmin:label key="membership.membershipName"/></th>
				<td><input type="text" name="membershipName" id="membershipName"	value="${membership.membershipName}" class="inputtxt" style="width:350px" maxLength="64"/></td>
			</tr>
			<tr>
				<th> <StoreAdmin:label key="membership.membershipLevel"/></th>
				<td><c:choose>
						<c:when test="${(not empty membership.membershipId) and membership.baseMembership}"> ${membership.membershipLevel} (<fmt:message key="membership.membershipLevel.default.tip"/>) </c:when>
						<c:otherwise>
							<input type="text" class="inputtxt" style="width:100px" name="membershipLevel" id="membershipLevel" value="${membership.membershipLevel}" />
						</c:otherwise>
					</c:choose></td>
			</tr>
			<tr>
				<th valign="top"> <StoreAdmin:label key="membership.membershipDetail"/></th>
				<td><textarea name="membershipDetail" id="membershipDetail"	class="textareatxt" style="width:350px" rows="6">${membership.membershipDetail}</textarea></td>
			</tr>
			<tr>
				<th colspan="2" class="title"><h4>
						<fmt:message key="membership.group.intro"/>
					</h4></th>
			</tr>
			<tr>
				<th> <StoreAdmin:label key="membership.upgradeShopPoint"/></th>
				<td><c:choose>
						<c:when test="${(not empty membership.membershipId) and membership.baseMembership}"> ${membership.upgradeShopPoint} (<fmt:message key="membership.upgradeShopPoint.default.tip"/>) </c:when>
						<c:otherwise>
							<input type="text" class="inputtxt" style="width:100px" name="upgradeShopPoint" id="upgradeShopPoint" value="${membership.upgradeShopPoint}" />
						</c:otherwise>
					</c:choose></td>
			</tr>
			<tr>
				<th valign="top"> <StoreAdmin:label key="membership.upgradeTips"/></th>
				<td><textarea name="upgradeTips" id="upgradeTips"	class="textareatxt" style="width:350px" rows="6">${membership.upgradeTips}</textarea></td>
			</tr>
		</table>
	</div>
</form>
<script type="text/javascript">
	var isNeedSetRole=true;
	var selRoleIds=new Array();
	window.onload=function(){
		if(!isNeedSetRole) return;
		<c:forEach items="${membership.appRoles}" var="role" varStatus="i">
			selRoleIds[${i.index}]=${role.roleId};
		</c:forEach>
		var roleSelector=$("appRoleIds");
		for(var i=0;i<selRoleIds.length;i++){
			for(var j=0;j<roleSelector.options.length;j++){
				if(selRoleIds[i]==roleSelector.options[j].value){
					roleSelector.options[j].selected=true;
					break;
				}
			}
		}
	}
</script>
<c:set var="ui_QuickTip" value="true"  scope="request"/>
